import { MvData, Mvs, mvPlayUrl } from '@/modules/Mv';
import { getMvPlay, getMvUrl, getSimiMv } from '@/utils/api';
import { createSlice } from '@reduxjs/toolkit'

const mvSlice = createSlice({
    name: 'mvSlice',
    initialState: {
        mvURL: {} as MvData,
        mvPlayURL: {} as mvPlayUrl,
        mvs: [] as Mvs[]
    },
    reducers: {

    },
    extraReducers: (builder) => {
        builder.addCase(getMvUrl.fulfilled, (state, action) => {
            if (action.payload) {
                state.mvURL = action.payload
            }
        });
        builder.addCase(getMvPlay.fulfilled, (state, action) => {
            if (action.payload) {
                console.log(action.payload)
                state.mvPlayURL = action.payload
            }
        });
        builder.addCase(getSimiMv.fulfilled, (state, action) => {
            if (action.payload) {
                console.log(action.payload)
                state.mvs = action.payload
            }
        });
    }
})


export const { } = mvSlice.actions

export const { reducer: mvReducer } = mvSlice